package yang.itcode.service.impl;

import cn.hutool.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yang.itcode.mapper.SystemSettingMapper;
import yang.itcode.model.pojo.SystemSetting;
import yang.itcode.service.SystemSettingService;

@Service
public class SystemSettingServiceImpl implements SystemSettingService {

    @Autowired
    private SystemSettingMapper systemSettingMapper;

    @Override
    public JSONObject getSystemSetting() {
        SystemSetting systemSetting = systemSettingMapper.select();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("imageAddress", systemSetting.getImageAddress());
        return jsonObject;
    }

    @Override
    public boolean updateImageAddress(String imageAddress) {
        SystemSetting systemSetting = new SystemSetting();
        systemSetting.setImageAddress(imageAddress);
        return systemSettingMapper.update(systemSetting) == 1;
    }
}
